#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：auto-test 
@File    ：find_img.py
@Author  ：赵加响
@Date    ：2023/1/6 14:46 
@Desc    ：
"""

import aircv as ac

from common.tools import get_image_path


class FindImage:

    def img_imread(self, image_path):
        """
        读取图片
        :param image_path:
        :return:
        """
        return ac.imread(image_path)

    def get_confidence(self, source_path, search_path):
        """
        查找图片
        :param source_path: 原图路径
        :param search_path: 需要查找的图片的路径
        :return:
        """
        source_image = self.img_imread(source_path)
        search_image = self.img_imread(search_path)
        result = ac.find_template(source_image, search_image)
        print(result['confidence'])
        return result['confidence']


if __name__ == '__main__':
    source = get_image_path('search.png')
    print(source)
    search = get_image_path('source.png')
    print(search)
    FindImage().get_confidence(source, search)
